package pachet.doi;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;

public class Laborator2 extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.laborator2);
        final RadioButton maleButton = (RadioButton) findViewById(R.id.radioButton1);
        final RadioButton femaleButton = (RadioButton) findViewById(R.id.radioButton2);

        final EditText textArea = (EditText) findViewById(R.id.editText2);
        
        
        
        maleButton.setOnClickListener(new View.OnClickListener() {
        	@Override
        	public void onClick(View v) {
        		femaleButton.setChecked(false);
        	}
        });
        
        femaleButton.setOnClickListener(new View.OnClickListener() {
        	@Override
        	public void onClick(View v) {
        		maleButton.setChecked(false);
        	}
        });
        
        
        
        final Button button = (Button) findViewById(R.id.button1);
        
        button.setOnClickListener(new View.OnClickListener() {
			
        	int count = 0;
        	
			@Override
			public void onClick(View v) {

//		        final RadioButton maleButton = (RadioButton) findViewById(R.id.radioButton1);
//		        final RadioButton femaleButton = (RadioButton) findViewById(R.id.radioButton2);
		        final EditText name = (EditText) findViewById(R.id.editText1);
		        String toInsert = "";
		        if (maleButton.isChecked())
		        	toInsert += maleButton.getText();
		        if (femaleButton.isChecked())
		        	toInsert += femaleButton.getText();
		        toInsert += ":" + name.getText();
		        textArea.setText( ((count>0) ? (textArea.getText() + "\n") : "") + toInsert);
		        count++;
			} 
		});
    }
}